package com.neusoft.mapper;

import com.neusoft.po.Orders;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;

import java.util.List;

@Mapper
public interface OrdersMapper {

	@Insert("insert into orders(userId,businessId,orderDate,orderTotal,daId,orderState) values(#{userId},#{businessId},#{orderDate},#{orderTotal},#{daId},0)")
	@Options(useGeneratedKeys = true, keyProperty = "orderId", keyColumn = "orderId")
	public int saveOrders(Orders order);

	public Orders getOrdersById(Integer orderId);

	public List<Orders> listOrdersByUserId(String userId);

	/*
	 * // if orderState = 0, there's no matched tuple, should report error
	 * 
	 * @Update("update orders set orderState=1 where orderId=#{orderId} and orderState=0"
	 * ) public int payOrders(Integer orderId);
	 * 
	 * @Delete("delete from orders where orderId=#{orderId}") public int
	 * removeOrders(Orders orders);
	 */
}
